package cn.gogetter.classifiers;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class ListToString {
	public static void main(String[] args) throws Exception{
		/*List<String> options = new ArrayList<String>();
		options.add("-D");
		options.add("-M");
		options.add("2");
		options.add("-L");
		String str = options.stream().collect(Collectors.joining(" "));
		System.out.println(str);*/
		
		Student s1 = new Student(1L, "xiaoming","1ban");
		Student s2 = new Student(2L, "zhangsan","1ban");
		Student s3 = new Student(3L, "lisi","2ban");
		Student s4 = new Student(4L, "wangwu","2ban");
		
		List<Student> list =new ArrayList<Student>();
		list.add(s1);
		list.add(s2);
		list.add(s3);
		list.add(s4);
		
		Map<Long,Student> map = list.stream().collect(Collectors.toMap(Student::getId,e->{
			e.setName("aaa");
			return e;
			
		},(e1,e2)->e2));
		System.out.println(map);
		
		Map<String,List<Student>> groupMap = list.stream().collect(Collectors.groupingBy(Student::getBaneji));
		System.out.println(groupMap);
		
		for(int i=0;i<list.size();i++){
			System.out.println(list.get(i));
		}
		
		for(Student s:list){
			print(s);
		}
		
		list.forEach(e->{
			print(e);
		});
	}
	
	public static void print(Student e){
		System.out.println(e.getId());
	}
}
